package main

import (
	"flag"
	"gitee.com/baal1990/epidemic/core"
	"gitee.com/baal1990/epidemic/global"
	"gitee.com/baal1990/epidemic/initialize"
	"go.uber.org/zap"
)

//go:generate go env -w GO111MODULE=on
//go:generate go env -w GOPROXY=https://goproxy.cn,direct
//go:generate go mod tidy
//go:generate go mod download

// @title Swagger Example API
// @version 0.0.1
// @description This is a sample Server pets
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name x-token
// @BasePath /
func main() {
	var privateKeyFile = flag.String("private_key_file", "private.key", "private key file")
	var publicKeyFile = flag.String("public_key_file", "public.key", "private key file")
	global.GVA_VP = core.Viper() // 初始化Viper
	global.GVA_LOG = core.Zap()  // 初始化zap日志库
	zap.ReplaceGlobals(global.GVA_LOG)
	global.GVA_DB = initialize.Gorm() // gorm连接数据库
	initialize.Redis()                // 初始化redis服务
	initialize.Timer()
	initialize.DBList()
	initialize.InitCrypto(*privateKeyFile, *publicKeyFile) // 初始化加密
	//if global.GVA_DB != nil {
	//	initialize.RegisterTables(global.GVA_DB) // 初始化表
	//	// 程序结束前关闭数据库链接
	//	db, _ := global.GVA_DB.DB()
	//	defer db.Close()
	//}
	core.RunWindowsServer()
}
